package com.ruoyi.gzs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gzs.domain.GzsHumidity;
import com.ruoyi.gzs.service.IGzsHumidityService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 湿度管理Controller
 * 
 * @author Liurenyi
 * @date 2022-06-29
 */
@RestController
@RequestMapping("/humidity/humidity")
public class GzsHumidityController extends BaseController
{
    @Autowired
    private IGzsHumidityService gzsHumidityService;

    /**
     * 查询湿度管理列表
     */
    @PreAuthorize("@ss.hasPermi('humidity:humidity:list')")
    @GetMapping("/list")
    public TableDataInfo list(GzsHumidity gzsHumidity)
    {
        startPage();
        List<GzsHumidity> list = gzsHumidityService.selectGzsHumidityList(gzsHumidity);
        return getDataTable(list);
    }

    /**
     * 导出湿度管理列表
     */
    @PreAuthorize("@ss.hasPermi('humidity:humidity:export')")
    @Log(title = "湿度管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GzsHumidity gzsHumidity)
    {
        List<GzsHumidity> list = gzsHumidityService.selectGzsHumidityList(gzsHumidity);
        ExcelUtil<GzsHumidity> util = new ExcelUtil<GzsHumidity>(GzsHumidity.class);
        util.exportExcel(response, list, "湿度管理数据");
    }

    /**
     * 获取湿度管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('humidity:humidity:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(gzsHumidityService.selectGzsHumidityById(id));
    }

    /**
     * 新增湿度管理
     */
    @PreAuthorize("@ss.hasPermi('humidity:humidity:add')")
    @Log(title = "湿度管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GzsHumidity gzsHumidity)
    {
        return toAjax(gzsHumidityService.insertGzsHumidity(gzsHumidity));
    }

    /**
     * 修改湿度管理
     */
    @PreAuthorize("@ss.hasPermi('humidity:humidity:edit')")
    @Log(title = "湿度管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GzsHumidity gzsHumidity)
    {
        return toAjax(gzsHumidityService.updateGzsHumidity(gzsHumidity));
    }

    /**
     * 删除湿度管理
     */
    @PreAuthorize("@ss.hasPermi('humidity:humidity:remove')")
    @Log(title = "湿度管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(gzsHumidityService.deleteGzsHumidityByIds(ids));
    }
}
